package com.meshnetics.gb.type.impl.zcl;

import com.meshnetics.gb.type.DataTypeID;

/**
 * WRITE DESCRIPTION HERE
 *
 * @author AKovylin
 */
public class TypeBitmap extends FixedBytesDataType {
    private static final String ALIAS_PREFIX = "bitmap";
    private static final String ID_TYPE_CLASS = "Bitmap";
    private static final String ID_DATA_TYPE_POSTFIX = "-bit bitmap";

    public static final TypeBitmap BITMAP_8 = new TypeBitmap(1,
            new DataTypeID((byte) 0x18, ID_TYPE_CLASS, 8 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_16 = new TypeBitmap(2,
            new DataTypeID((byte) 0x19, ID_TYPE_CLASS, 16 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_24 = new TypeBitmap(3,
            new DataTypeID((byte) 0x1a, ID_TYPE_CLASS, 24 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_32 = new TypeBitmap(4,
            new DataTypeID((byte) 0x1b, ID_TYPE_CLASS, 32 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_40 = new TypeBitmap(5,
            new DataTypeID((byte) 0x1c, ID_TYPE_CLASS, 40 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_48 = new TypeBitmap(6,
            new DataTypeID((byte) 0x1d, ID_TYPE_CLASS, 48 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_56 = new TypeBitmap(7,
            new DataTypeID((byte) 0x1e, ID_TYPE_CLASS, 56 + ID_DATA_TYPE_POSTFIX));
    public static final TypeBitmap BITMAP_64 = new TypeBitmap(8,
            new DataTypeID((byte) 0x1f, ID_TYPE_CLASS, 64 + ID_DATA_TYPE_POSTFIX));

    protected TypeBitmap(int byteSize, DataTypeID dataTypeId) {
        this(new String[]{ALIAS_PREFIX + byteSize * BITS_IN_BYTE}, dataTypeId, byteSize);
    }

    protected TypeBitmap(String[] aliases, DataTypeID dataTypeId, int byteSize) {
        super(aliases, dataTypeId, byteSize);
    }

    // no byte array cloning needed
    protected FixedBytesDataValue createValue(byte[] bytes) {
        return new Bitmap(this, bytes);
    }
}
